<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <?php
  echo "for 循环用于您预先知道脚本需要运行的次数的情况。<br>";
  for ($i = 1; $i <= 5; $i++) {
    echo "数字为 " . $i .  "<br>";
  }
  ?>

  <?php
  echo "foreach 循环用于遍历数组。<br>";
  $x = array("Google", "Runoob", "Taobao");
  foreach ($x as $value) {
    echo $value . '<br>';
  }
  ?>


  <?php
  $x = array(1 => "Google", 2 => "Runoob", 3 => "Taobao");
  foreach ($x as $key => $value) {
    echo "key  为 " . $key . "，对应的 value 为 " . $value . PHP_EOL;
  }
  ?>
</body>

</html>